Skip to content

docs: give every package a doc comment and enforce it - #753

Merged
CybotTM merged 1 commit into
mainfrom
docs/package-comments
Jul 28, 2026
Merged

docs: give every package a doc comment and enforce it#753
CybotTM merged 1 commit into
mainfrom
docs/package-comments

Conversation

@CybotTM

@CybotTM CybotTM commented Jul 28, 2026

Copy link
Copy Markdown
Member

Fixes the "no documentation" state on pkg.go.dev.

Why the page was empty

Not an indexing or license problem — there genuinely was no documentation. go doc . returned nothing.

The module root is package main, and the only comment above the package clause is the SPDX header:

// Copyright (c) 2025-2026 Netresearch DTT GmbH
// SPDX-License-Identifier: MITblank line
package main

Go treats a comment block as package documentation only when it is immediately adjacent to the package clause. The blank line separates it, so there was no doc comment. (The blank line is correct — without it pkg.go.dev would render the copyright header as the package description.)

Nine of fifteen packages were in that state: the root plus cli, config, core, metrics, middlewares, static, test, web. The packages added more recently (core/adapters/*, core/domain, core/ports, core/persist, test/testutil) already had comments.

What this changes

A doc.go per undocumented package, describing what it actually does rather than restating its name. The root one doubles as the command's documentation, which is what pkg.go.dev renders for a command module:

Ofelia is a job scheduler for Docker hosts, and a replacement for cron in
container environments. Jobs are declared in an INI file, through labels on the
containers themselves, or at runtime through the web API, and run either inside
an existing container, in a fresh one, on the host, or as a Swarm service.
...

Making it stick

Documentation that nothing enforces drifts back, which is how this happened: revive's package-comments rule was already in .golangci.yml — explicitly disabled: true.

Enabling it was not enough. The rule stayed silent because the comments exclusion preset filtered it out. Removing that preset makes the rule effective, but also surfaces 50 findings about missing comments on exported symbols — a separate and much larger question. So the exported-symbol rule keeps its current exemption through a targeted exclusion (text: '^exported: '), and only the package-comment requirement becomes blocking.

Net config change is three lines:

       - name: package-comments
-        disabled: true
...
-      - comments
+      - linters:
+          - revive
+        text: '^exported: '

Verification

Enforcement proven in both directions, not assumed:

Result
with the doc files golangci-lint run0 issues
with one doc.go deleted exactly 1 finding: package-comments: should have a package comment

Also: go doc . now returns the command documentation; go list -f '{{.Doc}}' ./... reports a synopsis for all 15 packages; build and vet clean under the default and integration tags; go test -race ./... 14/14.

Note that pkg.go.dev will still show the previous release until a tag containing this lands — the page currently serves v0.27.0 and has not yet picked up v0.28.0.

pkg.go.dev showed "There is no documentation for this package" for the
module root because there was none: the module root is package main, the
only comment above the package clause is the SPDX header, and a blank line
separates it, so Go does not read it as a doc comment. `go doc .` returned
nothing at all. Nine of fifteen packages were in the same state — the root
plus cli, config, core, metrics, middlewares, static, test and web.

Add a doc.go per undocumented package describing what it actually does.
The root one doubles as the command's documentation, which is what
pkg.go.dev renders for a command module.

Enforce it so it cannot drift again. revive's package-comments rule was
present but disabled, and even after enabling it the rule stayed silent:
the `comments` exclusion preset filtered it out. Dropping that preset makes
the rule effective but also surfaces 50 findings about missing comments on
exported symbols, which is a separate and much larger question — so the
exported-symbol rule keeps its exemption through a targeted exclusion, and
only the package-comment requirement becomes blocking.

Verified in both directions rather than assumed: with the doc files in
place golangci-lint reports 0 issues, and removing a single doc.go produces
exactly one finding, "should have a package comment".

Signed-off-by: Sebastian Mendel <info@sebastianmendel.de>
Copilot AI review requested due to automatic review settings July 28, 2026 05:51

@github-actions github-actions Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated approval for maintainer PR

All automated quality gates passed. See SECURITY_CONTROLS.md for compensating controls.

@github-actions

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

@sonarqubecloud

Copy link
Copy Markdown

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions

Copy link
Copy Markdown

⚠️ Mutation Testing Results

Mutation Score: 0.00% (threshold: 60%)

⚠️ Score is below threshold. Consider improving test coverage or test quality.

What is mutation testing?

Mutation testing measures test quality by introducing small changes (mutations) to the code and checking if tests detect them. A higher score means better test effectiveness.

  • Killed mutants: Tests caught the mutation (good!)
  • Survived mutants: Tests missed the mutation (needs improvement)

@codecov

codecov Bot commented Jul 28, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 87.63%. Comparing base (a3782c1) to head (ee7bda2).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #753      +/-   ##
==========================================
- Coverage   87.66%   87.63%   -0.04%     
==========================================
  Files          90       90              
  Lines       12058    12058              
==========================================
- Hits        10571    10567       -4     
- Misses       1196     1199       +3     
- Partials      291      292       +1     
Flag Coverage Δ
integration 87.63% <ø> (-0.02%) ⬇️
unittests 85.20% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@CybotTM
CybotTM added this pull request to the merge queue Jul 28, 2026
Merged via the queue into main with commit 6262d19 Jul 28, 2026
27 of 28 checks passed
@CybotTM
CybotTM deleted the docs/package-comments branch July 28, 2026 06:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants